package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	import ru.valyard.smart9slice.Abstract9Slice;
	import ru.valyard.smart9slice.Smart9Slice;

	public dynamic class Test extends Sprite
	{
		private var border: Sprite;
		private var line: Sprite;
		
		public function Test()
		{
			super();
			stage.addEventListener( MouseEvent.MOUSE_DOWN, handlerDown );
			border = getChildByName( "border_mc" ) as Abstract9Slice;
			line = getChildByName( "line_mc" ) as Abstract9Slice;
			border.width = border.height = line.width = 200;
		}
		
		private function handlerDown( evt: Event ): void
		{
			stage.addEventListener( MouseEvent.MOUSE_MOVE, handlerMouseMove );
			stage.addEventListener( MouseEvent.MOUSE_UP, handlerUp );
		}
		
		private function handlerUp( evt: Event ): void
		{
			stage.removeEventListener( MouseEvent.MOUSE_MOVE, handlerMouseMove );
			stage.removeEventListener( MouseEvent.MOUSE_UP, handlerUp );
		}
		
		private function handlerMouseMove( evt: MouseEvent ): void
		{
			border.width = mouseX - border.x;
			border.height = mouseY - border.y;
			
			line.width = mouseX - line.x;
			
			evt.updateAfterEvent();
		}
		
	}
}